package com.hejjon.controller;

import com.hejjon.base.BaseController;
import com.hejjon.bean.BookBean;
import com.hejjon.bean.FileStoreInfo;
import com.hejjon.bean.ResponseResult;
import com.hejjon.service.IFileManageService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RestController
@RequestMapping("/book")
public class BookController extends BaseController {

    @Resource
    private IFileManageService fileManageService;


    @PostMapping("/saveBook")
    public ResponseResult<?> saveBook(@ModelAttribute BookBean book) {

        System.out.println(book.getBookName() + "---" + book.getAuthor());
        System.out.println(book.getFile());
        MultipartFile file = book.getFile();
        long size = file.getSize();
        System.out.println(size);
        FileStoreInfo fileStoreInfo = fileManageService.uploadFile(file);
        System.out.println(fileStoreInfo);

        return success(null);
    }


}
